package com.rslai.base.tool.servertest.command;

import com.rslai.base.tool.servertest.context.Context;
import com.rslai.base.tool.servertest.model.KeyValueStore;
import com.rslai.base.tool.servertest.response.Response;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class EchoCommand extends ParameterizedCommand {
    public EchoCommand(List<KeyValueStore> params) {
        super(params);
    }

    protected Response doExecuteInternal(Response preResult, List<KeyValueStore> processedParams, Context context) throws Throwable {
        Response response = new Response();
        response.setBody(((KeyValueStore) processedParams.get(0)).getValue());
        return response;
    }

    protected StepCommand doClone() {
        return new EchoCommand(this.params);
    }

    public Map<String, Object> toReport() {
        Map details = new HashMap();
        details.put("stepName", "echo");
        List params = new ArrayList();
        details.put("params", params);
        return details;
    }
}
